
<template>
  <el-dialog v-model="dialogTableVisible"
             title="专家评审详情"
             width="80%">
    <div>
      <div class="title-col">
        评分详情
      </div>
      <div>
        <el-descriptions  border column="2">
          <el-descriptions-item label="项目名称">
            {{data.reviewObjectName}}
          </el-descriptions-item>
          <el-descriptions-item label="评审结果">
            {{reviewInfo(data.reviewResult)}}
<!--            {{data.reviewResult}}-->
          </el-descriptions-item>
          <el-descriptions-item label="评审意见">
            {{data.reviewInfo}}
          </el-descriptions-item>
        </el-descriptions>
      </div>
      <div>
        <el-table
            :data="data.lv1"
            style="width: 100%"
            border
        >
          <el-table-column prop="lv1name" label="一级指标" width="200"></el-table-column>
          <el-table-column label="二级指标及分值">
            <template #default="{ row }">
              <el-table
                  :data="row.lv2"
                  style="width: 100%"
                  border
                  size="small"
              >
                <el-table-column prop="lv2name" label="二级指标"></el-table-column>
                <el-table-column prop="lv2mark" label="满分"></el-table-column>
                <el-table-column prop="reviewMark" label="评分"></el-table-column>
<!--                <el-table-column prop="reviewMark" label="评审得分">-->
<!--                  <template #default="{ row: subRow }">-->
<!--                    <el-input v-model="subRow.reviewMark"-->
<!--                              placeholder="请输入评审分数"-->
<!--                              @input="validateScore(subRow)"-->
<!--                    ></el-input>-->
<!--                  </template>-->
<!--                </el-table-column>-->
              </el-table>
            </template>
          </el-table-column>
        </el-table>
      </div>
<!--      <div class="href">-->
<!--        <div>申请书预览</div>-->
<!--        <div>评审指南预览</div>-->
<!--      </div>-->
<!--      <el-form :model="data" label-width="auto" >-->
<!--        <div>-->
<!--          <el-form-item label="评审意见">-->
<!--            <el-input v-model="data.reviewInfo" type="textarea" />-->
<!--          </el-form-item>-->
<!--        </div>-->
<!--        <div>-->
<!--          <el-form-item label="评审结果">-->
<!--            <el-radio-group v-model="data.reviewResult" >-->
<!--              <el-radio value="pass">建议通过</el-radio>-->
<!--              <el-radio value="noPass">不建议通过</el-radio>-->
<!--            </el-radio-group>-->
<!--          </el-form-item>-->
<!--        </div>-->
<!--      </el-form>-->
    </div>
    <template #footer>
      <div class="dialog-footer">
<!--        <el-button @click="handleSave">暂存</el-button>-->
<!--        <el-button type="primary" @click="submit">提交</el-button>-->
<!--        <el-button type="primary" @click="cs">重置</el-button>-->
        <el-button @click="dialogTableVisible = false">关闭</el-button>
      </div>
    </template>
  </el-dialog>
</template>
<script setup lang="ts">
import {reviewdetails,sumbitreviewdetails,resettest} from  './../../api/specialist/specialistApi'
import {ElMessage} from "element-plus";
const reviewInfo = (status) => {
  switch (status) {
    case 'noPass':
      return '不建议通过';
    case 'pass':
      return '建议通过';
    case 'submit':
      return '已提交';
    case 'refuseReview':
      return '拒评';
    default:
      return status;
  }
};
const data = ref(
    // {historyspecialistDetails
    //   applyFile: "93977c3184005ed58084ba70e4749064,f0603b01978b35a6a122e615d9191bae",
    //   expertReviewId: "专家评审测试_1",
    //   "lv1": [
    //     {
    //       "standardId": "REVIEW_STANDARD_ID_1",
    //       "lv1name": "内容质量",
    //       "orderId": 0,
    //       "lv2": [
    //         {
    //           "lv2name": "准确性",
    //           "lv2mark": "20",
    //           "reviewMark": ""
    //         },
    //         {
    //           "lv2name": "深度与完整性",
    //           "lv2mark": "10",
    //           "reviewMark": ""
    //         },
    //         {
    //           "lv2name": "清晰度",
    //           "lv2mark": "10",
    //           "reviewMark": ""
    //         }
    //       ]
    //     },
    //     {
    //       "standardId": "REVIEW_STANDARD_ID_2",
    //       "lv1name": "创新性",
    //       "orderId": 1,
    //       "lv2": [
    //         {
    //           "lv2name": "独特性",
    //           "lv2mark": "10",
    //           "reviewMark": ""
    //         },
    //         {
    //           "lv2name": "前瞻性",
    //           "lv2mark": "10",
    //           "reviewMark": ""
    //         }
    //       ]
    //     },
    //     {
    //       "standardId": "REVIEW_STANDARD_ID_3",
    //       "lv1name": "呈现方式",
    //       "orderId": 2,
    //       "lv2": [
    //         {
    //           "lv2name": "视觉效果",
    //           "lv2mark": "10",
    //           "reviewMark": ""
    //         },
    //         {
    //           "lv2name": "语言表达",
    //           "lv2mark": "10",
    //           "reviewMark": ""
    //         }
    //       ]
    //     },
    //     {
    //       "standardId": "REVIEW_STANDARD_ID_4",
    //       "lv1name": "影响力",
    //       "orderId": 3,
    //       "lv2": [
    //         {
    //           "lv2name": "受众共鸣",
    //           "lv2mark": "10",
    //           "reviewMark": ""
    //         },
    //         {
    //           "lv2name": "传播潜力",
    //           "lv2mark": "10",
    //           "reviewMark": ""
    //         }
    //       ]
    //     }
    //   ],
    //   planFile: null,
    //   reviewInfo: null,
    //   reviewObjectName: "INFO_1_POSTMAN 白雪book1",
    //   reviewResult: null,
    // }
)
const csid = ref('')

const dialogTableVisible = ref(false)
const open = (row)=>{
  csid.value = row.expertReviewId
  reviewdetails({
    expertReviewId: row.expertReviewId
  }).then((res)=>{
    if(res.code = 200){
      data.value = res.data
      dialogTableVisible.value = true
    }
  })
}
const validateScore = (subRow) => {
  const maxScore = parseInt(subRow.lv2mark);
  const currentScore = parseInt(subRow.reviewMark);
  if (!isNaN(currentScore) && currentScore > maxScore) {
    subRow.reviewMark = maxScore.toString();
  }
}

//测试重置
const cs = function (){
  resettest({
    expertReviewId:csid.value
  })
      .then((res)=>{
        if(res.code == 200){
          //alert('123')
        }
      })
}
//暂存
const handleSave = function (){
 console.log(data.value)
  sumbitreviewdetails({
    ...data.value,
    reviewStatus:'notSubmit'
  })
      .then((res)=>{
        if(res.code == 200){
          ElMessage({
            type: 'success',
            message: res.msg
          });
          dialogTableVisible.value = false
        }else {
          ElMessage({
            type: 'info',
            message: res.msg
          });
        }
      })
}
//提交
const submit = function (){
  console.log(data.value)
  sumbitreviewdetails({
    ...data.value,
    reviewStatus:'submit'
  })
      .then((res)=>{
        if(res.code == 200){
          ElMessage({
            type: 'success',
            message: res.msg
          });
          dialogTableVisible.value = false
        }else {
          ElMessage({
            type: 'info',
            message: res.msg
          });
        }
      })
}
defineExpose({
  open
})
</script>


<style scoped lang="scss">
.dialog-footer {
  display: flex;
  justify-content: center;
  gap: 10px;
}
.href{
  width: 100%;
  display: flex;
  justify-content: flex-end;
  color:#23527c;
  margin: 20px 0;
}
.href > div{
  margin: 0 10px;
}
.href > div:hover{
  color:#23527c;
  cursor: pointer;
  text-decoration: underline;
}
.title-col {
  color: #337AB7;
  font-weight: bolder;
  margin: 10px 0;
}
</style>